//
//  ZYBaseTableViewController.swift
//  ZYWeibo
//
//  Created by Mac on 15/10/26.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class ZYBaseTableViewController: UITableViewController {
    
    let userLogin = false
    
    var visitorView: ZYVisitorView?
    
    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()
    }

    ///创建访客视图
    func setupVisitorView(){
        visitorView = ZYVisitorView()  // 创建view
        visitorView?.visitorViewDelegate = self 
        view = visitorView
        
//        view.backgroundColor = UIColor.whiteColor()
        if(self is ZYHomeTableViewController){ //首页
            visitorView?.rotationIcon()  //旋转转轮
        }else if (self is ZYDiscoverTableViewController){  //发现
            visitorView!.setupView("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }else if (self is ZYMessageTableViewController){ //消息
            visitorView!.setupView("visitordiscover_image_message", message: "消息。。。。。")
        }else if self is ZYProfileTableViewController {
            visitorView?.setupView("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        //创建导航栏上面的两个按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLogin")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

///分类   实现ZYVisitorViewDelegate的代理方法
extension ZYBaseTableViewController: ZYVisitorViewDelegate{
    func visitorViewRegister() {
        print(__FUNCTION__)
    }
    
    func visitorViewLogin() {
        print(__FUNCTION__)
    }
}
